package com.ruoyi.common.flowable;

import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.service.SysUserServiceImpl;
import org.flowable.common.engine.api.delegate.event.FlowableEvent;
import org.flowable.common.engine.api.delegate.event.FlowableEventListener;
import org.flowable.engine.HistoryService;
import org.flowable.engine.RepositoryService;
import org.flowable.engine.TaskService;
import org.flowable.engine.delegate.event.impl.FlowableProcessStartedEventImpl;
import org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl;
import org.springframework.stereotype.Component;

/**
 * 任务节点前置监听处理类
 * @author: Lu Yang
 * @create: 2019-05-04 20:51
 **/
@Component
public class ProcessStartedListener implements FlowableEventListener {

    public SysUserServiceImpl getSysUserService() {
        return SpringUtils.getBean(SysUserServiceImpl.class);
    }

    public TaskService getTaskService() {
        return SpringUtils.getBean(TaskService.class);
    }

    public RepositoryService getRepositoryService() {
        return SpringUtils.getBean(RepositoryService.class);
    }

    public HistoryService getHistoryService() {
        return SpringUtils.getBean(HistoryService.class);
    }
/*
    private List<String> getSponsorDirector(Long deptId){
        List<String> users = getSysUserService().getBaseMapper().getSponsorDirector(deptId);
        return users;
    }

    private List<String> getSponsorColleague(Long deptId){
        List<String> users = getSysUserService().getBaseMapper().getSponsorDirector(deptId);
        return users;
    }*/



    @Override
    public void onEvent(FlowableEvent event) {

        // 当前节点任务实体
        ExecutionEntityImpl  taskEntity = (ExecutionEntityImpl) ((FlowableProcessStartedEventImpl) event).getEntity();

        System.out.println("1111111111");
    }

    @Override
    public boolean isFailOnException() {
        return false;
    }

    @Override
    public boolean isFireOnTransactionLifecycleEvent() {
        return false;
    }

    @Override
    public String getOnTransaction() {
        return null;
    }
}